{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第二章习题\n",
    "\n",
    "### 一、填空题\n",
    "\n",
    "1.列表的`sort()`方法没有返回值,或者说返回值为________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.已知列表 `data=[1,2,30 4]`，那么`data[2:100]`的值为________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[30,4]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.己知`x=3`和`y=5`,那么执行语句`x,y=y,x`之后，`y`的值为________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．已知字典 `data= {'a;97, 'A' :65}`,那么`data.get('a', None)`的值为________."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "97"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 二、判断题\n",
    "\n",
    "1.生成器表达式的计算结果是一个元组。`(    )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "×"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2．包含列表的元组可以作为字典的“键”。`(    )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "×"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3．包含列表的元组不可以作为集合的元素。`(    )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "×"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．列表的`rindex()`方法返回指定元素在列表中最后一次出现的位置。`(    )`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "√"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 三、编程题\n",
    "\n",
    "1.输入一个字符串，输出其中每个字符的出现次数。要求使用标准库`collotections`中的`Counter`类,请自行查阅相关用法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import Counter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串，输出其中每个字符的次数:5678910\n"
     ]
    }
   ],
   "source": [
    "text = input('请输入一个字符串，输出其中每个字符的次数:')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Counter({'5': 1, '6': 1, '7': 1, '8': 1, '9': 1, '1': 1, '0': 1})\n"
     ]
    }
   ],
   "source": [
    "print(Counter(text))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2．输入一个字符串,输出其中只出现了一次的字符及其下标。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串，输出其中只出现了一次的字符及其下标:245678910\n"
     ]
    }
   ],
   "source": [
    "text = input('请输入一个字符串，输出其中只出现了一次的字符及其下标:')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "positions = [(ch,index) for index,ch in enumerate(text) \n",
    "                         if text.index(ch) == text.rindex(ch)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('2', 0), ('4', 1), ('5', 2), ('6', 3), ('7', 4), ('8', 5), ('9', 6), ('1', 7), ('0', 8)]\n"
     ]
    }
   ],
   "source": [
    "print(positions)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3．输入一个字符串,输出其中每个唯一字符最后一次出现的下标。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串:996233\n"
     ]
    }
   ],
   "source": [
    "x = input('请输入一个字符串:')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "for z in x:\n",
    "     d[z] = d.get(z,0)+1\n",
    "for y in d:\n",
    "    if d[y] == 1:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "print(x.index(y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4．输入包含若干集合的列表，输出这些集合的并集。提示:使用`reduce()`函数和`operator`模块中的运算实现多个集合的并集。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from functools import reduce"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个列表:[233,499,34,48]\n"
     ]
    }
   ],
   "source": [
    "lstA = eval(input(\"请输入一个列表:\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "507\n"
     ]
    }
   ],
   "source": [
    "print(reduce(lambda x, y: x | y, lstA))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5．输入一个字符串,检查该字符串是否为回文（正着读和反看读都一样的字符串)，如果是就输出`Yes`，否则输出`No`。要求使用切片实现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串'45,6,78,4'\n"
     ]
    }
   ],
   "source": [
    "s = eval(input('请输入一个字符串'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No\n"
     ]
    }
   ],
   "source": [
    "x = s[::-1]\n",
    "if s == x:\n",
    "    print('Yes')\n",
    "else:\n",
    "    print('No')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 课本上65页课后习题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、可迭代对象\n",
    "2、True\n",
    "3、None\n",
    "4、remove\n",
    "5、[6,7,9,11,13]\n",
    "6、{}，键、值、键\n",
    "7、items()、keys()、values() \n",
    "8、c=dict(zipla,b))\n",
    "9、b=a[::3]\n",
    "10、[5 fot i in range(10)]\n",
    "11、不可以"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "12、"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = ['sfcgtrtj46680','34fsr','68hff','dd','0.2']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['sfcgtrtj46680', '34fsr', '68hff', '0.2']\n"
     ]
    }
   ],
   "source": [
    "print(list(filter(lambda s:len(set(s))/len(s)>0.5,data)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "def prime(x):\n",
    "    for i in range(2,x):\n",
    "        if x%i==0:\n",
    "            return False\n",
    "        if i==x-1:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]\n"
     ]
    }
   ],
   "source": [
    "output=filter(prime,range(0,1001))\n",
    "print(list(output))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "14、列表的insert（）方法可以在列表的任意位置插入元素，但由于列表的自动内存管理功能，insert（）方法会涉及插入位置之后所有元素的移动，会影响处理速度\n",
    "15、"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[27, 27, 72, 43, 19, 23, 31, 34, 22, 0, 59, 70, 42, 72, 91, 73, 55, 66, 62, 71, 69, 3, 58, 63, 79, 97, 0, 78, 74, 60, 84, 17, 49, 20, 7, 77, 53, 12, 98, 70, 99, 16, 16, 58, 67, 40, 78, 56, 51, 73, 68, 6, 80, 38, 94, 68, 71, 71, 14, 57, 48, 23, 57, 67, 79, 94, 46, 81, 67, 92, 68, 56, 83, 45, 74, 73, 18, 98, 39, 57, 32, 68, 32, 100, 66, 90, 6, 98, 20, 50, 9, 46, 26, 37, 99, 70, 25, 18, 63, 3, 51, 65, 68, 69, 73, 58, 21, 14, 98, 87, 16, 54, 34, 33, 71, 46, 6, 38, 17, 34, 84, 63, 56, 34, 73, 46, 20, 44, 3, 87, 85, 19, 71, 2, 39, 90, 66, 55, 1, 26, 1, 26, 31, 0, 100, 6, 12, 84, 56, 66, 36, 65, 12, 4, 24, 90, 47, 96, 67, 43, 47, 85, 91, 30, 57, 68, 31, 32, 62, 68, 91, 59, 18, 34, 25, 7, 7, 34, 53, 2, 58, 26, 83, 91, 36, 66, 59, 35, 14, 1, 24, 49, 56, 91, 7, 27, 63, 68, 55, 21, 98, 3, 35, 83, 61, 11, 99, 25, 34, 49, 62, 57, 48, 11, 13, 1, 66, 7, 20, 58, 8, 89, 69, 11, 22, 46, 19, 17, 44, 8, 22, 29, 27, 1, 17, 38, 35, 49, 6, 91, 67, 99, 99, 98, 21, 92, 1, 83, 82, 49, 56, 55, 36, 72, 29, 44, 0, 10, 87, 69, 64, 1, 88, 68, 4, 37, 64, 31, 35, 67, 41, 9, 9, 7, 84, 7, 28, 53, 39, 88, 19, 48, 88, 43, 88, 35, 35, 18, 67, 54, 5, 74, 92, 13, 49, 61, 33, 87, 40, 40, 85, 46, 48, 24, 44, 22, 72, 89, 8, 99, 30, 97, 55, 51, 29, 78, 94, 38, 86, 67, 73, 16, 45, 38, 84, 18, 97, 36, 50, 17, 8, 0, 13, 30, 32, 70, 45, 31, 13, 91, 5, 90, 38, 68, 60, 79, 35, 21, 3, 57, 86, 86, 91, 37, 56, 78, 89, 13, 35, 1, 21, 27, 83, 24, 59, 100, 83, 43, 17, 3, 76, 5, 63, 33, 37, 51, 48, 34, 71, 29, 44, 91, 8, 94, 88, 81, 40, 70, 8, 95, 94, 53, 36, 2, 58, 50, 3, 29, 50, 38, 28, 23, 50, 26, 91, 80, 14, 43, 18, 89, 8, 34, 39, 58, 55, 81, 8, 39, 78, 79, 43, 77, 47, 25, 42, 90, 68, 58, 21, 43, 98, 9, 21, 30, 94, 85, 83, 53, 24, 93, 2, 5, 40, 88, 12, 15, 5, 57, 61, 65, 49, 35, 22, 38, 72, 97, 72, 51, 73, 87, 15, 44, 34, 11, 93, 39, 70, 25, 79, 63, 80, 10, 80, 53, 1, 93, 8, 42, 39, 44, 71, 34, 25, 55, 17, 41, 57, 69, 36, 68, 78, 91, 10, 98, 26, 21, 18, 65, 44, 50, 81, 66, 93, 58, 94, 12, 10, 84, 67, 1, 77, 30, 3, 11, 65, 36, 50, 57, 2, 86, 0, 23, 27, 34, 42, 94, 77, 35, 17, 75, 54, 56, 89, 7, 82, 40, 24, 41, 69, 89, 20, 17, 97, 11, 13, 46, 58, 67, 44, 35, 65, 22, 26, 18, 72, 79, 38, 41, 65, 69, 39, 38, 33, 20, 97, 53, 35, 11, 74, 12, 15, 58, 94, 83, 4, 7, 31, 3, 17, 60, 44, 48, 68, 49, 69, 25, 85, 65, 83, 71, 33, 22, 40, 58, 16, 49, 77, 73, 73, 64, 37, 23, 81, 13, 20, 77, 6, 88, 39, 90, 45, 95, 33, 83, 5, 32, 30, 21, 53, 71, 19, 71, 81, 11, 95, 50, 77, 64, 44, 34, 1, 77, 4, 95, 18, 75, 74, 48, 31, 97, 90, 97, 13, 28, 53, 22, 6, 77, 97, 31, 44, 10, 70, 87, 0, 72, 60, 46, 64, 98, 37, 99, 94, 11, 9, 56, 54, 53, 7, 72, 50, 76, 62, 81, 23, 33, 96, 60, 37, 2, 27, 74, 87, 2, 26, 35, 92, 80, 81, 9, 86, 20, 12, 81, 12, 36, 17, 34, 70, 75, 3, 22, 98, 95, 35, 3, 49, 31, 76, 2, 78, 41, 82, 69, 52, 12, 1, 47, 75, 40, 2, 100, 54, 55, 90, 30, 45, 26, 22, 49, 83, 83, 38, 2, 26, 43, 7, 15, 0, 47, 61, 53, 58, 87, 46, 11, 44, 88, 77, 7, 36, 97, 13, 16, 78, 62, 37, 1, 33, 75, 32, 59, 3, 12, 14, 32, 90, 88, 84, 44, 79, 82, 56, 81, 57, 89, 15, 79, 46, 34, 85, 62, 66, 99, 17, 42, 30, 20, 67, 62, 50, 31, 64, 86, 10, 95, 7, 74, 79, 66, 56, 12, 33, 59, 88, 21, 65, 75, 84, 71, 98, 94, 76, 13, 77, 26, 3, 99, 81, 66, 84, 44, 83, 27, 53, 4, 98, 79, 19, 15, 93, 21, 27, 66, 7, 33, 93, 37, 29, 96, 39, 30, 59, 19, 69, 98, 70, 21, 89, 38, 78, 21, 92, 50, 36, 80, 24, 3, 36, 31, 3, 41, 14, 75, 44, 2, 80, 96, 25, 77, 44, 80, 58, 100, 64, 38, 53, 75, 37, 50, 91, 90, 0, 71, 97, 96, 27, 27, 75, 40, 44, 59, 14, 39, 36, 62, 0, 16, 24, 39, 82, 69, 33, 67, 30, 88, 38, 62, 51, 3, 31, 17, 30, 80, 17, 13, 95, 49, 1, 97, 80, 84, 94, 6, 82, 29, 45, 15, 77, 83, 39, 92, 1, 15, 33, 19, 100, 74, 4, 95, 51, 37, 4, 56, 69, 57, 47, 33, 74, 17, 42, 91, 99, 7, 30, 63, 65, 86, 58, 13, 15, 44, 44, 86, 6, 56, 25, 53, 43, 94, 77, 65, 73, 38, 11, 78, 10, 70, 38, 29, 28, 47, 51, 38, 37, 32, 70, 52, 96, 15, 3, 56, 76, 59, 15, 34, 86, 68, 6, 53]\n",
      "27 : 11\n",
      "27 : 11\n",
      "72 : 9\n",
      "43 : 9\n",
      "19 : 8\n",
      "23 : 6\n",
      "31 : 12\n",
      "34 : 16\n",
      "22 : 10\n",
      "0 : 10\n",
      "59 : 9\n",
      "70 : 11\n",
      "42 : 6\n",
      "72 : 9\n",
      "91 : 13\n",
      "73 : 10\n",
      "55 : 8\n",
      "66 : 11\n",
      "62 : 9\n",
      "71 : 12\n",
      "69 : 12\n",
      "3 : 17\n",
      "58 : 15\n",
      "63 : 7\n",
      "79 : 10\n",
      "97 : 12\n",
      "0 : 10\n",
      "78 : 10\n",
      "74 : 9\n",
      "60 : 5\n",
      "84 : 10\n",
      "17 : 15\n",
      "49 : 12\n",
      "20 : 9\n",
      "7 : 15\n",
      "77 : 14\n",
      "53 : 15\n",
      "12 : 11\n",
      "98 : 13\n",
      "70 : 11\n",
      "99 : 10\n",
      "16 : 7\n",
      "16 : 7\n",
      "58 : 15\n",
      "67 : 12\n",
      "40 : 9\n",
      "78 : 10\n",
      "56 : 14\n",
      "51 : 8\n",
      "73 : 10\n",
      "68 : 14\n",
      "6 : 10\n",
      "80 : 10\n",
      "38 : 17\n",
      "94 : 13\n",
      "68 : 14\n",
      "71 : 12\n",
      "71 : 12\n",
      "14 : 7\n",
      "57 : 11\n",
      "48 : 7\n",
      "23 : 6\n",
      "57 : 11\n",
      "67 : 12\n",
      "79 : 10\n",
      "94 : 13\n",
      "46 : 10\n",
      "81 : 11\n",
      "67 : 12\n",
      "92 : 6\n",
      "68 : 14\n",
      "56 : 14\n",
      "83 : 14\n",
      "45 : 6\n",
      "74 : 9\n",
      "73 : 10\n",
      "18 : 9\n",
      "98 : 13\n",
      "39 : 13\n",
      "57 : 11\n",
      "32 : 8\n",
      "68 : 14\n",
      "32 : 8\n",
      "100 : 6\n",
      "66 : 11\n",
      "90 : 10\n",
      "6 : 10\n",
      "98 : 13\n",
      "20 : 9\n",
      "50 : 12\n",
      "9 : 6\n",
      "46 : 10\n",
      "26 : 11\n",
      "37 : 12\n",
      "99 : 10\n",
      "70 : 11\n",
      "25 : 9\n",
      "18 : 9\n",
      "63 : 7\n",
      "3 : 17\n",
      "51 : 8\n",
      "65 : 11\n",
      "68 : 14\n",
      "69 : 12\n",
      "73 : 10\n",
      "58 : 15\n",
      "21 : 13\n",
      "14 : 7\n",
      "98 : 13\n",
      "87 : 8\n",
      "16 : 7\n",
      "54 : 5\n",
      "34 : 16\n",
      "33 : 13\n",
      "71 : 12\n",
      "46 : 10\n",
      "6 : 10\n",
      "38 : 17\n",
      "17 : 15\n",
      "34 : 16\n",
      "84 : 10\n",
      "63 : 7\n",
      "56 : 14\n",
      "34 : 16\n",
      "73 : 10\n",
      "46 : 10\n",
      "20 : 9\n",
      "44 : 20\n",
      "3 : 17\n",
      "87 : 8\n",
      "85 : 6\n",
      "19 : 8\n",
      "71 : 12\n",
      "2 : 11\n",
      "39 : 13\n",
      "90 : 10\n",
      "66 : 11\n",
      "55 : 8\n",
      "1 : 15\n",
      "26 : 11\n",
      "1 : 15\n",
      "26 : 11\n",
      "31 : 12\n",
      "0 : 10\n",
      "100 : 6\n",
      "6 : 10\n",
      "12 : 11\n",
      "84 : 10\n",
      "56 : 14\n",
      "66 : 11\n",
      "36 : 12\n",
      "65 : 11\n",
      "12 : 11\n",
      "4 : 7\n",
      "24 : 8\n",
      "90 : 10\n",
      "47 : 7\n",
      "96 : 6\n",
      "67 : 12\n",
      "43 : 9\n",
      "47 : 7\n",
      "85 : 6\n",
      "91 : 13\n",
      "30 : 12\n",
      "57 : 11\n",
      "68 : 14\n",
      "31 : 12\n",
      "32 : 8\n",
      "62 : 9\n",
      "68 : 14\n",
      "91 : 13\n",
      "59 : 9\n",
      "18 : 9\n",
      "34 : 16\n",
      "25 : 9\n",
      "7 : 15\n",
      "7 : 15\n",
      "34 : 16\n",
      "53 : 15\n",
      "2 : 11\n",
      "58 : 15\n",
      "26 : 11\n",
      "83 : 14\n",
      "91 : 13\n",
      "36 : 12\n",
      "66 : 11\n",
      "59 : 9\n",
      "35 : 14\n",
      "14 : 7\n",
      "1 : 15\n",
      "24 : 8\n",
      "49 : 12\n",
      "56 : 14\n",
      "91 : 13\n",
      "7 : 15\n",
      "27 : 11\n",
      "63 : 7\n",
      "68 : 14\n",
      "55 : 8\n",
      "21 : 13\n",
      "98 : 13\n",
      "3 : 17\n",
      "35 : 14\n",
      "83 : 14\n",
      "61 : 4\n",
      "11 : 11\n",
      "99 : 10\n",
      "25 : 9\n",
      "34 : 16\n",
      "49 : 12\n",
      "62 : 9\n",
      "57 : 11\n",
      "48 : 7\n",
      "11 : 11\n",
      "13 : 12\n",
      "1 : 15\n",
      "66 : 11\n",
      "7 : 15\n",
      "20 : 9\n",
      "58 : 15\n",
      "8 : 9\n",
      "89 : 8\n",
      "69 : 12\n",
      "11 : 11\n",
      "22 : 10\n",
      "46 : 10\n",
      "19 : 8\n",
      "17 : 15\n",
      "44 : 20\n",
      "8 : 9\n",
      "22 : 10\n",
      "29 : 8\n",
      "27 : 11\n",
      "1 : 15\n",
      "17 : 15\n",
      "38 : 17\n",
      "35 : 14\n",
      "49 : 12\n",
      "6 : 10\n",
      "91 : 13\n",
      "67 : 12\n",
      "99 : 10\n",
      "99 : 10\n",
      "98 : 13\n",
      "21 : 13\n",
      "92 : 6\n",
      "1 : 15\n",
      "83 : 14\n",
      "82 : 6\n",
      "49 : 12\n",
      "56 : 14\n",
      "55 : 8\n",
      "36 : 12\n",
      "72 : 9\n",
      "29 : 8\n",
      "44 : 20\n",
      "0 : 10\n",
      "10 : 7\n",
      "87 : 8\n",
      "69 : 12\n",
      "64 : 7\n",
      "1 : 15\n",
      "88 : 11\n",
      "68 : 14\n",
      "4 : 7\n",
      "37 : 12\n",
      "64 : 7\n",
      "31 : 12\n",
      "35 : 14\n",
      "67 : 12\n",
      "41 : 6\n",
      "9 : 6\n",
      "9 : 6\n",
      "7 : 15\n",
      "84 : 10\n",
      "7 : 15\n",
      "28 : 4\n",
      "53 : 15\n",
      "39 : 13\n",
      "88 : 11\n",
      "19 : 8\n",
      "48 : 7\n",
      "88 : 11\n",
      "43 : 9\n",
      "88 : 11\n",
      "35 : 14\n",
      "35 : 14\n",
      "18 : 9\n",
      "67 : 12\n",
      "54 : 5\n",
      "5 : 6\n",
      "74 : 9\n",
      "92 : 6\n",
      "13 : 12\n",
      "49 : 12\n",
      "61 : 4\n",
      "33 : 13\n",
      "87 : 8\n",
      "40 : 9\n",
      "40 : 9\n",
      "85 : 6\n",
      "46 : 10\n",
      "48 : 7\n",
      "24 : 8\n",
      "44 : 20\n",
      "22 : 10\n",
      "72 : 9\n",
      "89 : 8\n",
      "8 : 9\n",
      "99 : 10\n",
      "30 : 12\n",
      "97 : 12\n",
      "55 : 8\n",
      "51 : 8\n",
      "29 : 8\n",
      "78 : 10\n",
      "94 : 13\n",
      "38 : 17\n",
      "86 : 9\n",
      "67 : 12\n",
      "73 : 10\n",
      "16 : 7\n",
      "45 : 6\n",
      "38 : 17\n",
      "84 : 10\n",
      "18 : 9\n",
      "97 : 12\n",
      "36 : 12\n",
      "50 : 12\n",
      "17 : 15\n",
      "8 : 9\n",
      "0 : 10\n",
      "13 : 12\n",
      "30 : 12\n",
      "32 : 8\n",
      "70 : 11\n",
      "45 : 6\n",
      "31 : 12\n",
      "13 : 12\n",
      "91 : 13\n",
      "5 : 6\n",
      "90 : 10\n",
      "38 : 17\n",
      "68 : 14\n",
      "60 : 5\n",
      "79 : 10\n",
      "35 : 14\n",
      "21 : 13\n",
      "3 : 17\n",
      "57 : 11\n",
      "86 : 9\n",
      "86 : 9\n",
      "91 : 13\n",
      "37 : 12\n",
      "56 : 14\n",
      "78 : 10\n",
      "89 : 8\n",
      "13 : 12\n",
      "35 : 14\n",
      "1 : 15\n",
      "21 : 13\n",
      "27 : 11\n",
      "83 : 14\n",
      "24 : 8\n",
      "59 : 9\n",
      "100 : 6\n",
      "83 : 14\n",
      "43 : 9\n",
      "17 : 15\n",
      "3 : 17\n",
      "76 : 5\n",
      "5 : 6\n",
      "63 : 7\n",
      "33 : 13\n",
      "37 : 12\n",
      "51 : 8\n",
      "48 : 7\n",
      "34 : 16\n",
      "71 : 12\n",
      "29 : 8\n",
      "44 : 20\n",
      "91 : 13\n",
      "8 : 9\n",
      "94 : 13\n",
      "88 : 11\n",
      "81 : 11\n",
      "40 : 9\n",
      "70 : 11\n",
      "8 : 9\n",
      "95 : 8\n",
      "94 : 13\n",
      "53 : 15\n",
      "36 : 12\n",
      "2 : 11\n",
      "58 : 15\n",
      "50 : 12\n",
      "3 : 17\n",
      "29 : 8\n",
      "50 : 12\n",
      "38 : 17\n",
      "28 : 4\n",
      "23 : 6\n",
      "50 : 12\n",
      "26 : 11\n",
      "91 : 13\n",
      "80 : 10\n",
      "14 : 7\n",
      "43 : 9\n",
      "18 : 9\n",
      "89 : 8\n",
      "8 : 9\n",
      "34 : 16\n",
      "39 : 13\n",
      "58 : 15\n",
      "55 : 8\n",
      "81 : 11\n",
      "8 : 9\n",
      "39 : 13\n",
      "78 : 10\n",
      "79 : 10\n",
      "43 : 9\n",
      "77 : 14\n",
      "47 : 7\n",
      "25 : 9\n",
      "42 : 6\n",
      "90 : 10\n",
      "68 : 14\n",
      "58 : 15\n",
      "21 : 13\n",
      "43 : 9\n",
      "98 : 13\n",
      "9 : 6\n",
      "21 : 13\n",
      "30 : 12\n",
      "94 : 13\n",
      "85 : 6\n",
      "83 : 14\n",
      "53 : 15\n",
      "24 : 8\n",
      "93 : 6\n",
      "2 : 11\n",
      "5 : 6\n",
      "40 : 9\n",
      "88 : 11\n",
      "12 : 11\n",
      "15 : 11\n",
      "5 : 6\n",
      "57 : 11\n",
      "61 : 4\n",
      "65 : 11\n",
      "49 : 12\n",
      "35 : 14\n",
      "22 : 10\n",
      "38 : 17\n",
      "72 : 9\n",
      "97 : 12\n",
      "72 : 9\n",
      "51 : 8\n",
      "73 : 10\n",
      "87 : 8\n",
      "15 : 11\n",
      "44 : 20\n",
      "34 : 16\n",
      "11 : 11\n",
      "93 : 6\n",
      "39 : 13\n",
      "70 : 11\n",
      "25 : 9\n",
      "79 : 10\n",
      "63 : 7\n",
      "80 : 10\n",
      "10 : 7\n",
      "80 : 10\n",
      "53 : 15\n",
      "1 : 15\n",
      "93 : 6\n",
      "8 : 9\n",
      "42 : 6\n",
      "39 : 13\n",
      "44 : 20\n",
      "71 : 12\n",
      "34 : 16\n",
      "25 : 9\n",
      "55 : 8\n",
      "17 : 15\n",
      "41 : 6\n",
      "57 : 11\n",
      "69 : 12\n",
      "36 : 12\n",
      "68 : 14\n",
      "78 : 10\n",
      "91 : 13\n",
      "10 : 7\n",
      "98 : 13\n",
      "26 : 11\n",
      "21 : 13\n",
      "18 : 9\n",
      "65 : 11\n",
      "44 : 20\n",
      "50 : 12\n",
      "81 : 11\n",
      "66 : 11\n",
      "93 : 6\n",
      "58 : 15\n",
      "94 : 13\n",
      "12 : 11\n",
      "10 : 7\n",
      "84 : 10\n",
      "67 : 12\n",
      "1 : 15\n",
      "77 : 14\n",
      "30 : 12\n",
      "3 : 17\n",
      "11 : 11\n",
      "65 : 11\n",
      "36 : 12\n",
      "50 : 12\n",
      "57 : 11\n",
      "2 : 11\n",
      "86 : 9\n",
      "0 : 10\n",
      "23 : 6\n",
      "27 : 11\n",
      "34 : 16\n",
      "42 : 6\n",
      "94 : 13\n",
      "77 : 14\n",
      "35 : 14\n",
      "17 : 15\n",
      "75 : 9\n",
      "54 : 5\n",
      "56 : 14\n",
      "89 : 8\n",
      "7 : 15\n",
      "82 : 6\n",
      "40 : 9\n",
      "24 : 8\n",
      "41 : 6\n",
      "69 : 12\n",
      "89 : 8\n",
      "20 : 9\n",
      "17 : 15\n",
      "97 : 12\n",
      "11 : 11\n",
      "13 : 12\n",
      "46 : 10\n",
      "58 : 15\n",
      "67 : 12\n",
      "44 : 20\n",
      "35 : 14\n",
      "65 : 11\n",
      "22 : 10\n",
      "26 : 11\n",
      "18 : 9\n",
      "72 : 9\n",
      "79 : 10\n",
      "38 : 17\n",
      "41 : 6\n",
      "65 : 11\n",
      "69 : 12\n",
      "39 : 13\n",
      "38 : 17\n",
      "33 : 13\n",
      "20 : 9\n",
      "97 : 12\n",
      "53 : 15\n",
      "35 : 14\n",
      "11 : 11\n",
      "74 : 9\n",
      "12 : 11\n",
      "15 : 11\n",
      "58 : 15\n",
      "94 : 13\n",
      "83 : 14\n",
      "4 : 7\n",
      "7 : 15\n",
      "31 : 12\n",
      "3 : 17\n",
      "17 : 15\n",
      "60 : 5\n",
      "44 : 20\n",
      "48 : 7\n",
      "68 : 14\n",
      "49 : 12\n",
      "69 : 12\n",
      "25 : 9\n",
      "85 : 6\n",
      "65 : 11\n",
      "83 : 14\n",
      "71 : 12\n",
      "33 : 13\n",
      "22 : 10\n",
      "40 : 9\n",
      "58 : 15\n",
      "16 : 7\n",
      "49 : 12\n",
      "77 : 14\n",
      "73 : 10\n",
      "73 : 10\n",
      "64 : 7\n",
      "37 : 12\n",
      "23 : 6\n",
      "81 : 11\n",
      "13 : 12\n",
      "20 : 9\n",
      "77 : 14\n",
      "6 : 10\n",
      "88 : 11\n",
      "39 : 13\n",
      "90 : 10\n",
      "45 : 6\n",
      "95 : 8\n",
      "33 : 13\n",
      "83 : 14\n",
      "5 : 6\n",
      "32 : 8\n",
      "30 : 12\n",
      "21 : 13\n",
      "53 : 15\n",
      "71 : 12\n",
      "19 : 8\n",
      "71 : 12\n",
      "81 : 11\n",
      "11 : 11\n",
      "95 : 8\n",
      "50 : 12\n",
      "77 : 14\n",
      "64 : 7\n",
      "44 : 20\n",
      "34 : 16\n",
      "1 : 15\n",
      "77 : 14\n",
      "4 : 7\n",
      "95 : 8\n",
      "18 : 9\n",
      "75 : 9\n",
      "74 : 9\n",
      "48 : 7\n",
      "31 : 12\n",
      "97 : 12\n",
      "90 : 10\n",
      "97 : 12\n",
      "13 : 12\n",
      "28 : 4\n",
      "53 : 15\n",
      "22 : 10\n",
      "6 : 10\n",
      "77 : 14\n",
      "97 : 12\n",
      "31 : 12\n",
      "44 : 20\n",
      "10 : 7\n",
      "70 : 11\n",
      "87 : 8\n",
      "0 : 10\n",
      "72 : 9\n",
      "60 : 5\n",
      "46 : 10\n",
      "64 : 7\n",
      "98 : 13\n",
      "37 : 12\n",
      "99 : 10\n",
      "94 : 13\n",
      "11 : 11\n",
      "9 : 6\n",
      "56 : 14\n",
      "54 : 5\n",
      "53 : 15\n",
      "7 : 15\n",
      "72 : 9\n",
      "50 : 12\n",
      "76 : 5\n",
      "62 : 9\n",
      "81 : 11\n",
      "23 : 6\n",
      "33 : 13\n",
      "96 : 6\n",
      "60 : 5\n",
      "37 : 12\n",
      "2 : 11\n",
      "27 : 11\n",
      "74 : 9\n",
      "87 : 8\n",
      "2 : 11\n",
      "26 : 11\n",
      "35 : 14\n",
      "92 : 6\n",
      "80 : 10\n",
      "81 : 11\n",
      "9 : 6\n",
      "86 : 9\n",
      "20 : 9\n",
      "12 : 11\n",
      "81 : 11\n",
      "12 : 11\n",
      "36 : 12\n",
      "17 : 15\n",
      "34 : 16\n",
      "70 : 11\n",
      "75 : 9\n",
      "3 : 17\n",
      "22 : 10\n",
      "98 : 13\n",
      "95 : 8\n",
      "35 : 14\n",
      "3 : 17\n",
      "49 : 12\n",
      "31 : 12\n",
      "76 : 5\n",
      "2 : 11\n",
      "78 : 10\n",
      "41 : 6\n",
      "82 : 6\n",
      "69 : 12\n",
      "52 : 2\n",
      "12 : 11\n",
      "1 : 15\n",
      "47 : 7\n",
      "75 : 9\n",
      "40 : 9\n",
      "2 : 11\n",
      "100 : 6\n",
      "54 : 5\n",
      "55 : 8\n",
      "90 : 10\n",
      "30 : 12\n",
      "45 : 6\n",
      "26 : 11\n",
      "22 : 10\n",
      "49 : 12\n",
      "83 : 14\n",
      "83 : 14\n",
      "38 : 17\n",
      "2 : 11\n",
      "26 : 11\n",
      "43 : 9\n",
      "7 : 15\n",
      "15 : 11\n",
      "0 : 10\n",
      "47 : 7\n",
      "61 : 4\n",
      "53 : 15\n",
      "58 : 15\n",
      "87 : 8\n",
      "46 : 10\n",
      "11 : 11\n",
      "44 : 20\n",
      "88 : 11\n",
      "77 : 14\n",
      "7 : 15\n",
      "36 : 12\n",
      "97 : 12\n",
      "13 : 12\n",
      "16 : 7\n",
      "78 : 10\n",
      "62 : 9\n",
      "37 : 12\n",
      "1 : 15\n",
      "33 : 13\n",
      "75 : 9\n",
      "32 : 8\n",
      "59 : 9\n",
      "3 : 17\n",
      "12 : 11\n",
      "14 : 7\n",
      "32 : 8\n",
      "90 : 10\n",
      "88 : 11\n",
      "84 : 10\n",
      "44 : 20\n",
      "79 : 10\n",
      "82 : 6\n",
      "56 : 14\n",
      "81 : 11\n",
      "57 : 11\n",
      "89 : 8\n",
      "15 : 11\n",
      "79 : 10\n",
      "46 : 10\n",
      "34 : 16\n",
      "85 : 6\n",
      "62 : 9\n",
      "66 : 11\n",
      "99 : 10\n",
      "17 : 15\n",
      "42 : 6\n",
      "30 : 12\n",
      "20 : 9\n",
      "67 : 12\n",
      "62 : 9\n",
      "50 : 12\n",
      "31 : 12\n",
      "64 : 7\n",
      "86 : 9\n",
      "10 : 7\n",
      "95 : 8\n",
      "7 : 15\n",
      "74 : 9\n",
      "79 : 10\n",
      "66 : 11\n",
      "56 : 14\n",
      "12 : 11\n",
      "33 : 13\n",
      "59 : 9\n",
      "88 : 11\n",
      "21 : 13\n",
      "65 : 11\n",
      "75 : 9\n",
      "84 : 10\n",
      "71 : 12\n",
      "98 : 13\n",
      "94 : 13\n",
      "76 : 5\n",
      "13 : 12\n",
      "77 : 14\n",
      "26 : 11\n",
      "3 : 17\n",
      "99 : 10\n",
      "81 : 11\n",
      "66 : 11\n",
      "84 : 10\n",
      "44 : 20\n",
      "83 : 14\n",
      "27 : 11\n",
      "53 : 15\n",
      "4 : 7\n",
      "98 : 13\n",
      "79 : 10\n",
      "19 : 8\n",
      "15 : 11\n",
      "93 : 6\n",
      "21 : 13\n",
      "27 : 11\n",
      "66 : 11\n",
      "7 : 15\n",
      "33 : 13\n",
      "93 : 6\n",
      "37 : 12\n",
      "29 : 8\n",
      "96 : 6\n",
      "39 : 13\n",
      "30 : 12\n",
      "59 : 9\n",
      "19 : 8\n",
      "69 : 12\n",
      "98 : 13\n",
      "70 : 11\n",
      "21 : 13\n",
      "89 : 8\n",
      "38 : 17\n",
      "78 : 10\n",
      "21 : 13\n",
      "92 : 6\n",
      "50 : 12\n",
      "36 : 12\n",
      "80 : 10\n",
      "24 : 8\n",
      "3 : 17\n",
      "36 : 12\n",
      "31 : 12\n",
      "3 : 17\n",
      "41 : 6\n",
      "14 : 7\n",
      "75 : 9\n",
      "44 : 20\n",
      "2 : 11\n",
      "80 : 10\n",
      "96 : 6\n",
      "25 : 9\n",
      "77 : 14\n",
      "44 : 20\n",
      "80 : 10\n",
      "58 : 15\n",
      "100 : 6\n",
      "64 : 7\n",
      "38 : 17\n",
      "53 : 15\n",
      "75 : 9\n",
      "37 : 12\n",
      "50 : 12\n",
      "91 : 13\n",
      "90 : 10\n",
      "0 : 10\n",
      "71 : 12\n",
      "97 : 12\n",
      "96 : 6\n",
      "27 : 11\n",
      "27 : 11\n",
      "75 : 9\n",
      "40 : 9\n",
      "44 : 20\n",
      "59 : 9\n",
      "14 : 7\n",
      "39 : 13\n",
      "36 : 12\n",
      "62 : 9\n",
      "0 : 10\n",
      "16 : 7\n",
      "24 : 8\n",
      "39 : 13\n",
      "82 : 6\n",
      "69 : 12\n",
      "33 : 13\n",
      "67 : 12\n",
      "30 : 12\n",
      "88 : 11\n",
      "38 : 17\n",
      "62 : 9\n",
      "51 : 8\n",
      "3 : 17\n",
      "31 : 12\n",
      "17 : 15\n",
      "30 : 12\n",
      "80 : 10\n",
      "17 : 15\n",
      "13 : 12\n",
      "95 : 8\n",
      "49 : 12\n",
      "1 : 15\n",
      "97 : 12\n",
      "80 : 10\n",
      "84 : 10\n",
      "94 : 13\n",
      "6 : 10\n",
      "82 : 6\n",
      "29 : 8\n",
      "45 : 6\n",
      "15 : 11\n",
      "77 : 14\n",
      "83 : 14\n",
      "39 : 13\n",
      "92 : 6\n",
      "1 : 15\n",
      "15 : 11\n",
      "33 : 13\n",
      "19 : 8\n",
      "100 : 6\n",
      "74 : 9\n",
      "4 : 7\n",
      "95 : 8\n",
      "51 : 8\n",
      "37 : 12\n",
      "4 : 7\n",
      "56 : 14\n",
      "69 : 12\n",
      "57 : 11\n",
      "47 : 7\n",
      "33 : 13\n",
      "74 : 9\n",
      "17 : 15\n",
      "42 : 6\n",
      "91 : 13\n",
      "99 : 10\n",
      "7 : 15\n",
      "30 : 12\n",
      "63 : 7\n",
      "65 : 11\n",
      "86 : 9\n",
      "58 : 15\n",
      "13 : 12\n",
      "15 : 11\n",
      "44 : 20\n",
      "44 : 20\n",
      "86 : 9\n",
      "6 : 10\n",
      "56 : 14\n",
      "25 : 9\n",
      "53 : 15\n",
      "43 : 9\n",
      "94 : 13\n",
      "77 : 14\n",
      "65 : 11\n",
      "73 : 10\n",
      "38 : 17\n",
      "11 : 11\n",
      "78 : 10\n",
      "10 : 7\n",
      "70 : 11\n",
      "38 : 17\n",
      "29 : 8\n",
      "28 : 4\n",
      "47 : 7\n",
      "51 : 8\n",
      "38 : 17\n",
      "37 : 12\n",
      "32 : 8\n",
      "70 : 11\n",
      "52 : 2\n",
      "96 : 6\n",
      "15 : 11\n",
      "3 : 17\n",
      "56 : 14\n",
      "76 : 5\n",
      "59 : 9\n",
      "15 : 11\n",
      "34 : 16\n",
      "86 : 9\n",
      "68 : 14\n",
      "6 : 10\n",
      "53 : 15\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "x = [random.randint(0,100)for i in range(1000)]\n",
    "print(x)\n",
    "for i in x:\n",
    "    print(i,':',x.count(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
